package com.irdstudio.cdp.pboc.service.impl;

import java.util.List;
import java.util.Objects;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.irdstudio.cdp.pboc.service.dao.PbocOwingTaxesDao;
import com.irdstudio.cdp.pboc.service.domain.PbocOwingTaxes;
import com.irdstudio.cdp.pboc.service.facade.PbocOwingTaxesService;
import com.irdstudio.cdp.pboc.service.vo.PbocOwingTaxesVO;
import com.irdstudio.basic.framework.core.base.FrameworkService;
/**
 * <p>ServiceImpl: 欠税记录				<p>
 * @author ligm
 * @date 2018-12-26
 */
@Service("pbocOwingTaxesService")
public class PbocOwingTaxesServiceImpl implements PbocOwingTaxesService, FrameworkService {
	
	private static Logger logger = LoggerFactory.getLogger(PbocOwingTaxesServiceImpl.class);

	@Autowired
	private PbocOwingTaxesDao pbocOwingTaxesDao;
	
	/**
	 * 新增操作
	 */
	public int insertPbocOwingTaxes(PbocOwingTaxesVO inPbocOwingTaxesVo)  throws Exception {
		logger.debug("当前新增数据为:"+ inPbocOwingTaxesVo.toString());
		int num = 0;
		try {
			PbocOwingTaxes pbocOwingTaxes = new PbocOwingTaxes();
			beanCopy(inPbocOwingTaxesVo, pbocOwingTaxes);
			num = pbocOwingTaxesDao.insertPbocOwingTaxes(pbocOwingTaxes);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
			throw e;
		}
		logger.debug("当前新增数据条数为:"+ num);
		return num;
	}

	/**
	 * 删除操作
	 */
	public int deleteByPk(PbocOwingTaxesVO inPbocOwingTaxesVo)  throws Exception {
		logger.debug("当前删除数据条件为:"+ inPbocOwingTaxesVo);
		int num = 0;
		try {
			PbocOwingTaxes pbocOwingTaxes = new PbocOwingTaxes();
			beanCopy(inPbocOwingTaxesVo, pbocOwingTaxes);
			num = pbocOwingTaxesDao.deleteByPk(pbocOwingTaxes);
		} catch (Exception e) {
			logger.error("删除数据发生异常!", e);
			num = -1;
			throw e;
		}
		logger.debug("根据条件:"+ inPbocOwingTaxesVo +"删除的数据条数为"+ num);
		return num;
	}


	/**
	 * 更新操作
	 */
	public int updateByPk(PbocOwingTaxesVO inPbocOwingTaxesVo)  throws Exception {
		logger.debug("当前修改数据为:"+ inPbocOwingTaxesVo.toString());
		int num = 0;
		try {
			PbocOwingTaxes pbocOwingTaxes = new PbocOwingTaxes();
			beanCopy(inPbocOwingTaxesVo, pbocOwingTaxes);
			num = pbocOwingTaxesDao.updateByPk(pbocOwingTaxes);
		} catch (Exception e) {
			logger.error("修改数据发生异常!", e);
			num = -1;
			throw e;
		}
		logger.debug("根据条件:"+ inPbocOwingTaxesVo +"修改的数据条数为"+ num);
		return num;
	}
	
	/**
	 * 查询操作
	 */
	public PbocOwingTaxesVO queryByPk(PbocOwingTaxesVO inPbocOwingTaxesVo) {
		
		logger.debug("当前查询参数信息为:"+ inPbocOwingTaxesVo);
		try {
			PbocOwingTaxes queryPbocOwingTaxes = new PbocOwingTaxes();
			beanCopy(inPbocOwingTaxesVo, queryPbocOwingTaxes);
			PbocOwingTaxes queryRslPbocOwingTaxes = pbocOwingTaxesDao.queryByPk(queryPbocOwingTaxes);
			if (Objects.nonNull(queryRslPbocOwingTaxes)) {
				PbocOwingTaxesVO outPbocOwingTaxesVo = beanCopy(queryRslPbocOwingTaxes, new PbocOwingTaxesVO());
				logger.debug("当前查询结果为:"+ outPbocOwingTaxesVo.toString());
				return outPbocOwingTaxesVo;
			} else {
				logger.debug("当前查询结果为空!");
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
			throw e;
		}
		return null;
	}


	/**
	 * 查询用户权限数据
	 */
	@SuppressWarnings("unchecked")
	public List<PbocOwingTaxesVO> queryAllOwner(PbocOwingTaxesVO pbocOwingTaxesVo)  throws Exception {

		logger.debug("当前查询本人所属数据信息的参数信息为:");
		List<PbocOwingTaxesVO> list = null;
		try {
			List<PbocOwingTaxes> pbocOwingTaxess = pbocOwingTaxesDao.queryAllOwnerByPage(pbocOwingTaxesVo);
			logger.debug("当前查询本人所属数据信息的结果集数量为:"+ pbocOwingTaxess.size());
			pageSet(pbocOwingTaxess, pbocOwingTaxesVo);
			list = (List<PbocOwingTaxesVO>) beansCopy(pbocOwingTaxess, PbocOwingTaxesVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
			throw e;
		}
		
		return list;
	
	}


	/**
	 * 查询当前机构权限数据
	 */
	@SuppressWarnings("unchecked")
	public List<PbocOwingTaxesVO> queryAllCurrOrg(PbocOwingTaxesVO pbocOwingTaxesVo)  throws Exception {

		logger.debug("当前查询本人所属机构数据信息的参数信息为:");
		List<PbocOwingTaxes> pbocOwingTaxess = pbocOwingTaxesDao.queryAllCurrOrgByPage(pbocOwingTaxesVo);
		logger.debug("当前查询本人所属机构数据信息的结果集数量为:"+pbocOwingTaxess.size());
		List<PbocOwingTaxesVO> list = null;
		try {
			pageSet(pbocOwingTaxess, pbocOwingTaxesVo);
			list = (List<PbocOwingTaxesVO>) beansCopy(pbocOwingTaxess, PbocOwingTaxesVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
			throw e;
		}
		
		return list;
	
	}


	/**
	 * 查询当前机构及下属机构权限数据
	 */
	@SuppressWarnings("unchecked")
	public List<PbocOwingTaxesVO> queryAllCurrDownOrg(PbocOwingTaxesVO pbocOwingTaxesVo)  throws Exception {

		logger.debug("当前查询本人所属机构及以下数据信息的参数信息为:");
		List<PbocOwingTaxes> pbocOwingTaxess = pbocOwingTaxesDao.queryAllCurrDownOrgByPage(pbocOwingTaxesVo);
		logger.debug("当前查询本人所属机构及以下数据信息的结果集数量为:"+ pbocOwingTaxess.size());
		List<PbocOwingTaxesVO> list = null;
		try {
			pageSet(pbocOwingTaxess, pbocOwingTaxesVo);
			list = (List<PbocOwingTaxesVO>) beansCopy(pbocOwingTaxess, PbocOwingTaxesVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
			throw e;
		}
		
		return list;
	
	}
}
